<template>
  <div>
    <divider>人员列表</divider>

    <group>
      <datetime format="YYYY-MM" title="分数月度" v-model="time" value-text-align="center"></datetime>
      <x-input title="员工姓名" placeholder="员工姓名" v-model="userName" type="text"></x-input>
      <x-button type="primary" @click.native="getMember()">查询</x-button>
    </group>
    <group>
      <div>
      <x-table :cell-bordered="false" :content-bordered="false" style="background-color:#fff;">
        <thead>
          <tr style="background-color: #F7F7F7">
            <th>姓名</th>
            <th>绩效自评</th>
            <th>审核分数</th>
            <th>审批状态</th>
          </tr>
        </thead>
        <tbody v-for="(data,index) in memberlist">
          <tr>
            <td>{{data.name}}</td>
            <td v-if="data.selfScore==null">暂无</td>
            <td style="padding:2px 20px 2px 20px;text-align:right" v-else="data.selfScore!=null">
              <router-link v-if="data.tlScore==null" :to="'/tabbar/score-detail-ps?staffId='+data.staffId+'&year='+year+'&month='+month">{{data.selfScore}}</router-link>
              <span v-else="data.tlScore!=null">{{data.selfScore}}</span>
            </td>
            <td v-if="data.tlScore==null">暂无</td>
            <td style="padding:2px 20px 2px 20px;text-align:right" v-else="data.tlScore!=null">
              <router-link :to="'/tabbar/pfs?staffId='+data.staffId+'&year='+year+'&month='+month">{{data.tlScore}}</router-link>
            </td>
            <td v-if="data.tlScore==null">未审批</td>
            <td v-else="data.tlScore!=null">已审批</td>
          </tr>
        </tbody>
      </x-table>
      </div>
    </group>
  </div>
</template>

<script>
import { Group, Badge, XTable, Divider,Datetime,XButton,XInput} from 'vux'

export default {
  components: {
    Group,
    Badge,
    XTable,
    Divider,
    Datetime,
    XButton,
    XInput
  },
  data () {
    var ms_staffId = localStorage.getItem('ms_staffId')
    var currentDate = new Date()
    var currentTimeStr = currentDate.getFullYear() + '-' + (currentDate.getMonth() + 1)

    //时间格式
    var tempDateStr = ''
    var tempDates = new Array()
    tempDates = currentTimeStr.split('-')
    var tempMonth = ''
    tempMonth = tempDates[1]
    if (tempMonth >= 1 && tempMonth <= 9) {
      tempMonth = "0" + tempMonth
    }
    tempDateStr = tempDates[0] + '-' + tempMonth

    return {
      memberlist: [],
      tempDate: [],
      showContent001: false,
      staffIdOnLogin: ms_staffId,
      time: tempDateStr,
      year: currentDate.getFullYear(),
      month: currentDate.getMonth() + 1
    }
  },
  mounted: function () {
    this.getMember()
  },
  methods: {
    getMember: function () {
      var self = this
      console.log(self.time)
      var tempTime = []
      tempTime = self.time.split('-')
      self.month = tempTime[1]
      self.year = tempTime[0]
      self.$ajax({
        method: 'get',
        url: '../wx/performance/user',
        params: {
          staffId: self.staffIdOnLogin,
          month: self.month,
          year: self.year,
          userName:self.userName
        }
      })
      .then(function (res) {
        console.log(res)
        self.memberlist = res.data
      })
      .catch(function (err) {
        console.log(err)
      })
    },
    getdate: function () {
      var tempDateStr = ''
      this.tempDate = this.time.split('-')
      var tempMonth = ''
      tempMonth = this.tempDate[1]
      if (tempMonth >= 1 && tempMonth <= 9) {
        tempMonth = "0" + tempMonth
      }
      tempDateStr = this.tempDate[0] + '-' + tempMonth
      this.dateList = tempDateStr.split('-')
    },
  }
}
</script>
